# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器，以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。

ARG BUILD_CONFIGURATION=Release
ARG APP_UID=1000

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8081
HEALTHCHECK --interval=30s --timeout=3s \
  CMD curl -f http://localhost:6666/health || exit 1

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY ["MK.WebApplication.csproj", "."]
RUN dotnet restore "MK.WebApplication.csproj"
COPY . .
# 方法2：直接使用 Release
RUN dotnet build "MK.WebApplication.csproj" -c Release -o /app/build

FROM build AS publish
# 方法2：直接使用 Release
RUN dotnet publish "MK.WebApplication.csproj" -c Release -o /app/publish \
    /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MK.WebApplication.dll"]
